package com.been.common.action;

import org.aspectj.lang.ProceedingJoinPoint;

import static com.been.common.constants.ActionHandleContants.AJAX_ERROR_STRING;

/**
 * action层 ajax异常处理类
 * 
 * @author been 2011-10-06
 */
public class ActionAjaxExceptionHandle {
	
	/**
	 * 处理ajax异常
	 * @param joinPoint
	 * @throws Throwable
	 */
	public void doHandleAjaxException(ProceedingJoinPoint joinPoint)
			throws Throwable {
		PublicAction action = (PublicAction)joinPoint.getTarget();
		try {
			joinPoint.proceed();
		} catch (Exception e) {
			e.printStackTrace();
			action.getResponse().reset();
			action.writeText(AJAX_ERROR_STRING);
		}
	}
}
